草庐IT

C++ sizeof 包装类

全部标签

.net - GeoTrans p/调用包装器 NullReferenceException

我正在尝试公开需要从GeoTransc++库调用的方法,但遇到了问题。任何帮助都会很棒!我有以下c++文件,我正在运行nmake以将其编译成dll。#include#include"CoordinateConversionService.h"#include"CoordinateSystemParameters.h"#include"GeodeticParameters.h"#include"CoordinateTuple.h"#include"GeodeticCoordinates.h"#include"CartesianCoordinates.h"#include"Accuracy

c++ - sizeof... 是否允许在模板参数中用于特化?

我正在尝试使用GCC4.7快照做一些类似的事情:templatestructfoo{staticconstintvalue=0;};//partialspecializationwherenisnumberofintsinxs:templatestructfoo{//error:templateargument‘sizeof(xs...)’//involvestemplateparameter(s)staticconstintvalue=1;};templatestructfoo{//Thiscompilesfine.sizeof(xs)issizeofint//eventhoughp

c++ - 如何实现最简单的 C++ 可调用对象包装器?

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭10年前。我想实现一个行为如下所示的类FuncWrapper,但我发现它并不像预期的那么容易。intOrdinaryFunction(intn){returnn;}structFunctor{intoperator()(intn){returnn;}};intmain(){FuncWrapperf1(OrdinaryFunction);coutf2(functor);cout我的问题是:如何在PUREC+

c++ - 将 C++ 对象包装到 Node 插件中的 v8 对象

我目前正在用C++编写一个Node插件,我遇到了一个问题,我需要创建并返回一个v8数组,其中填充了v8包装的C++对象实例。目前,代码看起来像这样v8::HandleController::nodeArray(constv8::Arguments&args){v8::HandleScopescope;Controller*controller=ObjectWrap::Unwrap(args.This());conststd::vector*foobars=controller->getFoobars();unsignedintfoobarCount=foobars->size();v8

c++ - 为什么 sizeof...(T) 这么慢?在没有 sizeof...(T) 的情况下实现 C++14 make_index_sequence

我找到了C++14make_index_sequence“算法”的实现:templatestructindex_sequence{usingtype=index_sequence;};templateusinginvoke=typenameT::type;templatestructconcate;templatestructconcate,index_sequence>:index_sequence{};//\///----------//Ithinkhereisslowly.templatestructmake_index_sequence_help:concate>,invoke

C++ 用可变参数包装一个包装器宏?

问题我有一个方法可以通过用宏替换函数来包装函数,这样我就可以记录调用和返回代码。这是一个有效的示例:intrc;intfoo(inta,intb);intbar(inta,char*b,int*c);voidLogRet(char*fn,char*file,char*from,intln,intret){printf("%s.%s.%d:%s()ret:%08x\n",file,from,ln,fn,ret);}#definefoo(args,...)(rc=(foo)(args,##__VA_ARGS__),LogRet("foo",__FILE__,__FUNCTION__,__L

python - 使用 SWIG 打印为 Python 包装的 C++ 类时不调用 __str__()

我正在尝试使用SWIG打印我为Python包装的C++类。我遵循了文档和这个问题:Howtostringfyaswigmatrixobjectinpython扩展的__str__函数在那里,但是当我从Python打印对象时它没有被调用。让我举一个最小的例子:测试类.h#includeclassTestClass{private:intmy_int;public:TestClass():my_int(0){}friendstd::ostream&operator测试类.cpp#include"TestClass.h"intmain(){usingnamespacestd;TestClas

c++ - 如何在没有 sizeof 的情况下最好地防止自定义断言中出现未使用的变量警告?

基于http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/中的建议一段时间以来,我一直在使用我自己的断言版本(称为emp_assert)。因此,当设置NDEBUG时,我的断言如下所示:#defineemp_assert(EXPR)((void)sizeof(EXPR))此定义确保EXPR中的任何变量在编译器中仍算作“已使用”,但不会影响运行时性能。不幸的是,我最近发现在断言中使用lambda会产生编译错误,因为lambda不能放入sizeof。我的选择似乎是:简单地删除sizeof;我的代码中很少有未使用变

python - 使用 SWIG 为 Python 包装 C++。 'vector' 未声明

我正在尝试包装一个创建3Dvector的C++,以便我可以从Python调用它并可视化数据。我正在尝试使用SWIG包装,但是当我这样做时,我收到了错误消息'vector’wasnotdeclaredinthisscope并且在我能想到的每个文件中都包含了“vector”,但我不确定我必须做什么才能包含它。我已经创建了一组非常基本的测试函数来尝试查看问题出在哪里,它与我尝试运行的真实代码大致相似。测试.cpp#include#includeusingnamespacestd;vectortestfunction(vector&value){cout测试.h#ifndefTEST_H_//

c++ - 编译包装器时出现 SWIG [C++ to Lisp(CFFI)] 错误

我是C++和Lisp与SWIG之间接口(interface)的初学者。我遵循了SWIG的文档,但遇到了问题。这是我想要接口(interface)的简单程序(它可以很容易地在Lisp中完成,但它是为了了解如何将C++代码导入Lisp):测试.cpp:#include"test.hpp"inttest(intx,inty){std::cout测试.hpp:#includeinttest(intx,inty);为了使用SWIG,我创建了接口(interface)文件:测试.i:%moduletest%include然后,我执行了以下命令行:$swig-c++-cffitest.i$c++-c